
const modules = import.meta.globEager('./*-index.vue'); // 参数为组件路径
const componentsOpt:any = {};

const getCaption = (fillePath:string, delStr:string, isInOrder: boolean) => {
  let index = fillePath.lastIndexOf(delStr);
  if (isInOrder) index += delStr.length;
  // isInOrder为true则从左往右按顺序截取/之后的内容，反之
  fillePath = isInOrder ? fillePath.substring(index, fillePath.length) : fillePath.substring(0, index);
  return fillePath;
};

for (const path in modules) {
  let key = getCaption(path, './', true);
  key = getCaption(key, '.vue', false);
  componentsOpt[key] = modules[path]['default'];
}
export default componentsOpt;
